public class Calculate {
    public Calculate(double a, double b, double c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }
    private double a;
    private double b;
    private double c;
    public void solve() {
        double discriminant = b * b - 4 * a * c;
        if (discriminant > 0) {
            double x1 = (-b + Math.sqrt(discriminant)) / (2 * a);
            double x2 = (-b - Math.sqrt(discriminant)) / (2 * a);
            System.out.printf("方程有两个不同的实根: x1 = %.2f, x2 = %.2f%n", x1, x2);
        } else if (discriminant == 0) {
            double x = -b / (2 * a);
            System.out.printf("方程有一个实根: x = %.2f%n", x);
        } else {
            double realPart = -b / (2 * a);
            double imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
            System.out.printf("方程没有实根, 复数根为: x1 = %.2f + %.2fi, x2 = %.2f - %.2fi%n", realPart, imaginaryPart, realPart, imaginaryPart);
        }
    }
}